package com.mao;

public class ArrayDemo1 {
    public static void main(String[] args) {
        randomName();
    }
    //我是Java小白，请帮我开发一个随机点名的方法，假设有15个学生，随机点名一个学生
    public static void randomName(){
        //定义一个数组，存储15个学生的姓名
        //静态初始化数组
        //String[] names={"张三","李四","王五","赵六","孙七","周八","吴九","郑十","王十一","赵十二","孙十三","周十四","吴十五","郑十六","孙十七"};
        String names[] ={"张三","李四","王五","赵六","孙七","周八","吴九","郑十","王十一","赵十二","孙十三","周十四","吴十五","郑十六","孙十七"};
        //随机数
        //names.length是数组中的元素个数
        int index=(int)(Math.random()*names.length);
        System.out.println("随机点名："+names[index]);
    }
}
